"""
文件: pool.py
功能: 使用进程池同时启动大量子任务，会自动管理进程数量
"""

from multiprocessing import Pool
import time


def worker(x):
    time.sleep(1)
    return x * x


if __name__ == "__main__":
    with Pool(processes=4) as pool:
        results = pool.map(worker, [1, 2, 3, 4, 5])
        print("results", results)
